{include file='public/header' /}
<body>

    <div class="layui-fluid">

        <div class="layui-row">

            <form class="layui-form " enctype="multipart/form-data" id="file" style="margin: 50px;">

                <input type="hidden" name="id" value="{$info.id}" id="idval">

                <input type="hidden" name="zhang" value="{$info.zhang}">
               <div class="layui-form-item" id="imgdiv">
                      <div class="layui-upload-drag" id="test10">
                        <i class="layui-icon"></i>
                        <p style="color:#009688; font-weight: bold;">员工个人章</p>
                        <hr>
                        <p>点击上传，或将文件拖拽到此处</p>
                        <div id="uploadDemoView">
                          <hr>
                          <img src="{$info.zhang}" alt="上传成功后渲染" style="max-width: 196px">
                        </div>
                      </div>
               </div>

            </form>

        </div>

    </div>



    <script>
        layui.use('upload', function(){
          var $ = layui.jquery
          ,upload = layui.upload;
                 //拖拽上传 店铺logo
                  upload.render({
                    elem: '#test10'
                    ,url: '{:url("uploadfile/getfile")}' //改成您自己的上传接口
                    ,before: function(obj){
                      //预读本地文件示例，不支持ie8
                        obj.preview(function(index, file, result){
                        layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', result);
    
                      });
                    }   
                     ,done: function(res){
                           
                                        var id = $('#idval').val();
                                        var zhang = res.data.src;

                                        $.ajax({

                                            type:'post',

                                            url:"{:url('User/edit')}",

                                            data: {id:id,zhang:zhang},

                                              success:function(data){

                                                if (data.code == 1) {

                                                  layer.msg(data.message, {icon: 1,time: 1500});


                                                }else{

                                                  layer.msg('修改失败', {icon: 2,time: 1500});

                                                }

                                                

                                              }

                                            })

                        }
                  });

          });

    </script>


</body>

